package own.stu.jobgib.playown.util.ftp;

import static own.stu.jobgib.playown.util.ftp.FtpOperateEvent.DOWNLOAD;
import static own.stu.jobgib.playown.util.ftp.FtpOperateEvent.UPLOAD;

public class FtpCommandFactory {
    public static <P extends BaseParameter> FtpCommand create(Integer operateEvent, P p) {
        FtpCommand command = null;
        if (UPLOAD.equals(operateEvent)) {
            command = new FtpUploadCommand();
        } else if (DOWNLOAD.equals(operateEvent)) {
            command = new FtpDownloadCommand();
        } else {
            throw new RuntimeException("OperationNotSupported");
        }
        command.setParameter(p);
        return command;
    }
}
